<%@page import="warehouse.AccountBean"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>登录验证</title>
	<link rel="stylesheet" href="layui/css/layui.css">
	<script src="layui/layui.js"></script>
	
</head>
<body>
<%
	String username = request.getParameter("username");
	String password = request.getParameter("password");
	
	if(username==null || password==null){
		%>
		<script>
		layui.use('layer', function(){
			  var layer = layui.layer;
			  layer.alert('用户名或密码不能为空', function(index){
					window.location.href="login.jsp";
				}); 
			});  
		</script>
		<%	
	}
	else{
		AccountBean account = new AccountBean();
		boolean success = account.login(username, password);
		if(success){
			//登录成功
			session.setAttribute("account", account);
			
			response.sendRedirect("index.jsp");
		}else{
			%>
			<script>
			layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.alert('用户名或密码错误', function(index){
						window.location.href="login.jsp";
					}); 
				});  
			</script>
			<%	
		}
	}
	
	


%>
</body>
</html>